(function(){if(window.BX.seoParser)return;var t=window.BX,e=[];t.seoParser=function(e,s){this.textarea=s;this.contentData=[];this.editors=[];this.editors_index={};this.parseContent(e);t.ready(t.delegate(this.init,this))};t.seoParser.prototype.init=function(){this.textarea=t(this.textarea);t.bind(this.textarea,"change",t.delegate(this.parseContent,this))};t.seoParser.prototype.parseContent=function(e){this.contentData=[];if(typeof e=="undefined"||!t.type.isString(e)){e=this.textarea.value}if(e.length>0){var s=e.split(/\n+/g);var a="",i={name:"",data:[]},o;for(o=0;o<s.length;o++){var n=t.util.trim(s[o]);if(n.length>0){var r;if(/^#/.test(n)){r=[n]}else{r=n.split(/:\s*/);r=[r.shift(),r.join(":")]}if(r[0].toUpperCase()=="USER-AGENT"){if(a!==""){this.contentData.push(i)}a=r[1];i={name:a,data:[]}}else if(!!a){if(r[0].toUpperCase()=="DISALLOW"&&(!r[1]||r[1].replace(/#.*/,"")==="")){continue}i.data.push(r)}}}if(a!==""){this.contentData.push(i)}for(o=0;o<this.editors.length;o++){this.sendData(this.editors[o].getUserAgent())}}};t.seoParser.prototype.compile=function(){var e,s,a="",i="\r\n";for(e=0;e<this.contentData.length;e++){if(typeof this.editors_index[this.contentData[e].name.toUpperCase()]!="undefined"){delete this.contentData[e]}}for(e=0;e<this.editors.length;e++){this.contentData=t.util.insertIntoArray(this.contentData,e,{name:this.editors[e].getUserAgent(),data:this.editors[e].getRules()})}this.contentData=t.util.array_values(this.contentData);for(e=0;e<this.contentData.length;e++){if(t.type.isArray(this.contentData[e].data)&&this.contentData[e].data.length>0){a+=(a===""?"":i)+"User-Agent: "+this.contentData[e].name+i;for(s=0;s<this.contentData[e].data.length;s++){a+=this.contentData[e].data[s][0];if(typeof this.contentData[e].data[s][1]!="undefined"&&this.contentData[e].data[s][1].length>0){a+=": "+this.contentData[e].data[s][1]}a+=i}}}this.textarea.value=a};t.seoParser.prototype.registerEditor=function(t){this.editors_index[t.getUserAgent().toUpperCase()]=this.editors.length;this.editors.push(t);this.sendData(t.getUserAgent())};t.seoParser.prototype.sendData=function(t){t=t.toUpperCase();if(typeof this.editors_index[t]!="undefined"){for(var e=0;e<this.contentData.length;e++){if(this.contentData[e].name.toUpperCase()==t){this.editors[this.editors_index[t]].setRules(this.contentData[e].data||[]);return}}this.editors[this.editors_index[t]].setRules([])}};t.seoEditor=function(e){this.service=e.service;this.userAgent=e.userAgent;this.cont={rules:e.cont.rules,buttons:e.cont.buttons};this.rules=[];t.ready(t.delegate(this.init,this))};t.seoEditor.prototype.init=function(){this.cont.rules=t(this.cont.rules);this.cont.buttons=t(this.cont.buttons);this.build();this.buildButtons()};t.seoEditor.prototype.buildButtons=function(){var s=function(s,a){return function(i){e[s].callback(a);return t.PreventDefault(i)}};for(var a=0;a<e.length;a++){if(typeof e[a].compatible!="undefined"&&t.type.isArray(e[a].compatible)&&!t.util.in_array(this.service,e[a].compatible)){continue}this.cont.buttons.appendChild(t.create("DIV",{props:{className:"seo-robots-action"},children:[t.create("INPUT",{props:{type:"button",className:"seo-robots-action-button "+(e[a].className||"adm-btn"),name:e[a].name||"",value:e[a].text,title:e[a].title||""},events:{click:s(a,this)}})]}))}};t.seoEditor.prototype.build=function(){if(!t.isReady){t.ready(t.delegate(this.build,this));return}this.cont.rules.innerHTML="";this.cont.rules.appendChild(t.create("DIV",{text:"User-Agent: "+this.userAgent}));this.rules=t.util.array_values(this.rules);for(var e=0;e<this.rules.length;e++){if(!!this.rules[e]){var s=this.rules[e][0];if(typeof this.rules[e][1]!="undefined"&&this.rules[e][1].length>0)s+=": "+this.rules[e][1];this.cont.rules.appendChild(t.create("DIV",{props:{className:"seo-robots-entry"},children:[t.create("SPAN",{text:s}),t.create("SPAN",{props:{className:"seo-robots-delete"},events:{click:this.getDeleteAction(e)}})]}))}}};t.seoEditor.prototype.getDeleteAction=function(e){return t.delegate(function(){delete this.rules[e];this.build()},this)};t.seoEditor.prototype.getUserAgent=function(){return this.userAgent};t.seoEditor.prototype.getRules=function(t){var e=[],s=this.rules.length;if(!!t)t=t.toUpperCase();for(var a=0;a<s;a++){if(!t||t==this.rules[a][0].toUpperCase()){e.push([this.rules[a][0],this.rules[a][1]])}}return e};t.seoEditor.prototype.setRules=function(t,e){if(typeof e=="undefined"){this.rules=t}else{var s;for(s=0;s<this.rules.length;s++){if(!!this.rules[s]&&this.rules[s][0]==e){delete this.rules[s]}}if(!!t&&t.length>0){for(s=0;s<t.length;s++){this.rules.push([t[s][0],t[s][1]])}}}this.build()};t.seoEditor.prototype.addRule=function(t,e){if(!e){for(var s=0;s<this.rules.length;s++){if(!!this.rules[s]){if(this.rules[s][0]==t[0]&&this.rules[s][1]==t[1]){return}}}}this.rules.push([t[0],t[1]]);this.build()};var s=null;var a=["*/index.php","/bitrix/","/*show_include_exec_time=","/*show_page_exec_time=","/*show_sql_stat=","/*bitrix_include_areas=","/*clear_cache=","/*clear_cache_session=","/*ADD_TO_COMPARE_LIST","/*ORDER_BY","/*PAGEN","/*?print=","/*&print=","/*print_course=","/*?action=","/*&action=","/*register=","/*forgot_password=","/*change_password=","/*login=","/*logout=","/*auth=","/*backurl=","/*back_url=","/*BACKURL=","/*BACK_URL=","/*back_url_admin=","/*?utm_source=","/*?bxajaxid=","/*&bxajaxid=","/*?view_result=","/*&view_result="];var i=["/bitrix/components/","/bitrix/cache/","/bitrix/js/","/bitrix/templates/","/bitrix/panel/"];function o(){if(!s){s=new t.PopupWindow(Math.random(),null,{closeByEsc:true,closeIcon:true,titleBar:true,overlay:{backgroundColor:"black",opacity:"50"}});s.closeBtn=new t.PopupWindowButtonLink({text:t.message("JS_CORE_WINDOW_CLOSE"),className:"popup-window-button-link-cancel",events:{click:function(e){this.popupWindow.close();return t.PreventDefault(e)}}})}return s}function n(e,s){var a="seo_callback_"+parseInt(Math.random()*1e5);window[a]=e;var i={site:t.message("SEO_SITE_ID"),path:"/",view:"list",sort:"type",sort_order:"asc"};var o={submitFuncName:a,select:"FD",operation:"O",showUploadTab:false,showAddToMenuTab:false,site:t.message("SEO_SITE_ID"),path:"/",lang:t.message("LANGUAGE_ID"),fileFilter:"",allowAllFiles:false,saveConfig:true,sessid:t.bitrix_sessid(),checkChildren:true,genThumb:true,zIndex:2500};if(!!window.oBXFileDialog&&!!window.oBXFileDialog.UserConfig){i=window.oBXFileDialog.UserConfig;o.path=i.path}if(!!s){o.path=s}window.oBXFileDialog=new window.BXFileDialog;window.oBXFileDialog.Open(o,i)}e.push({name:"auto",compatible:["common"],text:t.message("SEO_ROBOT_ACTION_AUTO"),title:t.message("SEO_ROBOT_ACTION_AUTO_TITLE"),className:"adm-btn",callback:function(e){var s=t.message("SEO_HOST");var n=o();var r=e.getRules("Host");if(r.length>0){s=""}var l=function(){var o=[];var r=[];var l=[];var u=e.getRules("Disallow");var c;for(c=0;c<u.length;c++){if(typeof u[1]!="undefined"&&u[1]!==""){r.push(u[1])}}u=e.getRules("Allow");for(c=0;c<u.length;c++){if(typeof u[1]!="undefined"&&u[1]!==""){l.push(u[1])}}for(c=0;c<a.length;c++){if(!t.util.in_array(a[c],r)){e.addRule(["Disallow",a[c]])}}for(c=0;c<i.length;c++){if(!t.util.in_array(i[c],l)){e.addRule(["Allow",i[c]])}}if(s.length>0){e.addRule(["Host",s])}n.close()};if(s.length>0&&s.substring(0,4)!="www."){var u=t.create("DIV",{html:'<input type="text" value="www.'+t.util.htmlspecialchars(s)+'" class="seo-robots-settings-input">'});n.setTitleBar(t.message("SEO_ROBOT_ACTION_MAIN_HOST"));n.setContent(u);n.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){s=u.firstChild.value;l()}}}),n.closeBtn]);n.show()}else{l()}}});e.push({name:"disallow_url",text:t.message("SEO_ROBOT_ACTION_DISALLOW"),title:t.message("SEO_ROBOT_ACTION_DISALLOW_TITLE"),className:"adm-btn",callback:function(e){var s=e.getRules("Disallow");var a='<div class="seo-robots-settings-row"><input type="text" value="#PATH#" class="seo-robots-settings-input"><input type="button" value="..."></div>';var i="";for(var r=0;r<s.length+5;r++){i+=a.replace("#PATH#",t.util.htmlspecialchars((s[r]||["",""])[1]))}var l=t.create("DIV",{props:{className:"seo-robots-settings"},events:{click:t.delegateEvent({tagName:"INPUT",property:{type:"button",value:"..."}},function(){var t=this.previousSibling;n(function(e,s,a,i,o){t.value=s.replace(/\/+$/,"")+"/"+e},t.value)})},html:i});var u=o();u.setTitleBar(t.message("SEO_ROBOT_ACTION_DISALLOW_PATH"));u.setContent(l);u.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){var t=l.firstChild;var s=[];while(!!t){if(t.tagName.toUpperCase()=="DIV"&&!!t.firstChild&&t.firstChild.tagName.toUpperCase()=="INPUT"&&t.firstChild.type=="text"&&t.firstChild.value!==""){s.push(["Disallow",t.firstChild.value])}t=t.nextSibling}e.setRules(s,"Disallow");u.close()}}}),u.closeBtn]);u.show()}});e.push({name:"allow_url",text:t.message("SEO_ROBOT_ACTION_ALLOW"),title:t.message("SEO_ROBOT_ACTION_ALLOW_TITLE"),className:"adm-btn",callback:function(e){var s=e.getRules("Allow");var a='<div class="seo-robots-settings-row"><input type="text" value="#PATH#" class="seo-robots-settings-input"><input type="button" value="..."></div>';var i="";for(var r=0;r<s.length+5;r++){i+=a.replace("#PATH#",t.util.htmlspecialchars((s[r]||["",""])[1]))}var l=t.create("DIV",{props:{className:"seo-robots-settings"},events:{click:t.delegateEvent({tagName:"INPUT",property:{type:"button",value:"..."}},function(){var t=this.previousSibling;n(function(e,s,a,i,o){t.value=s.replace(/\/+$/,"")+"/"+e},t.value)})},html:i});var u=o();u.setTitleBar(t.message("SEO_ROBOT_ACTION_ALLOW_PATH"));u.setContent(l);u.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){var t=l.firstChild;var s=[];while(!!t){if(t.tagName.toUpperCase()=="DIV"&&!!t.firstChild&&t.firstChild.tagName.toUpperCase()=="INPUT"&&t.firstChild.type=="text"&&t.firstChild.value!==""){s.push(["Allow",t.firstChild.value])}t=t.nextSibling}e.setRules(s,"Allow");u.close()}}}),u.closeBtn]);u.show()}});e.push({name:"main_host",text:t.message("SEO_ROBOT_ACTION_MAIN_HOST"),title:t.message("SEO_ROBOT_ACTION_MAIN_HOST_TITLE"),className:"adm-btn",callback:function(e){var s=e.getRules("Host");var a=t.message("SEO_HOST"),i=location.protocol=="https:";if(s.length>0){a=s[0][1];if(a.substring(0,8)=="https://"){i=true;a=a.substring(8,a.length)}}var n='<form name="host_form">';n+='<div class="seo-robots-settings-row"><input type="checkbox" id="main_host_https" name="main_host_https"'+(i?' checked="checked"':"")+'><label for="main_host_https">&nbsp;https</label></div>';var r=a==t.message("SEO_HOST")||!a;var l=!r;n+='<div class="seo-robots-settings-row"><input type="radio" name="main_host" value="'+t.util.htmlspecialchars(t.message("SEO_HOST"))+'" id="main_host_1"'+(r?' checked="checked"':"")+'><label for="main_host_1">'+t.util.htmlspecialchars(t.message("SEO_HOST"))+"</label></div>";if(t.message("SEO_HOST").substring(0,4)!="www."){r=a=="www."+t.message("SEO_HOST");l&=!r;n+='<div class="seo-robots-settings-row"><input type="radio" name="main_host" value="www.'+t.util.htmlspecialchars(t.message("SEO_HOST"))+'" id="main_host_2"'+(r?' checked="checked"':"")+'><label for="main_host_2">www.'+t.util.htmlspecialchars(t.message("SEO_HOST"))+"</label></div>"}n+='<div class="seo-robots-settings-row"><input type="radio" name="main_host" value="" id="main_host_3"'+(l?' checked="checked"':"")+'><input type="text" name="main_host_value" value="'+(l?a:"")+'" onfocus="BX(\'main_host_3\').checked=true" class="seo-robots-settings-input"></div>';n+="</form>";var u=t.create("DIV",{props:{className:"seo-robots-settings"},html:n});var c=o();c.setTitleBar(t.message("SEO_ROBOT_MAIN_HOST"));c.setContent(u);c.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){var s=document.forms.host_form.main_host,a=t.message("SEO_HOST"),i=[];for(var o=0;o<s.length;o++){if(s[o].checked){a=s[o].value;break}}if(a===""){a=document.forms.host_form.main_host_value.value}if(a.length>0){if(document.forms.host_form.main_host_https.checked){a="https://"+a}i.push(["Host",a])}e.setRules(i,"Host");c.close()}}}),c.closeBtn]);c.show();t.adminFormTools.modifyFormElements(document.forms.host_form)}});e.push({name:"crawl_delay",text:t.message("SEO_ROBOT_ACTION_CRAWL_DELAY"),title:t.message("SEO_ROBOT_ACTION_CRAWL_DELAY_TITLE"),compatible:["common","yandex"],className:"adm-btn",callback:function(e){var s=e.getRules("Crawl-delay");var a=2;if(s.length>0&&!isNaN(parseInt(s[0][1]))){a=s[0][1]}var i='<input type="text" value="'+t.util.htmlspecialchars(a)+'" class="seo-robots-settings-input">';var n=t.create("DIV",{html:i});var r=o();r.setTitleBar(t.message("SEO_ROBOT_CRAWL_DELAY"));r.setContent(n);r.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){var t=n.lastChild,s=[];if(t.value.length>0){s.push(["Crawl-delay",t.value])}e.setRules(s,"Crawl-delay");r.close()}}}),r.closeBtn]);r.show()}});e.push({name:"sitemap",compatible:["common"],text:t.message("SEO_ROBOT_ACTION_SITEMAP"),title:t.message("SEO_ROBOT_ACTION_SITEMAP_TITLE"),className:"adm-btn",callback:function(e){var s="http://"+t.message("SEO_HOST");var a=e.getRules("Host");if(a.length>0){s=a[0][1];if(!/^http[s]{0,1}:\/\//.test(s)){s="http://"+s}}var i=s+"/sitemap.xml";var n='<input type="text" value="'+t.util.htmlspecialchars(i)+'" class="seo-robots-settings-input">';var r=t.create("DIV",{html:n});var l=o();l.setTitleBar(t.message("SEO_ROBOT_ACTION_SITEMAP_URL"));l.setContent(r);l.setButtons([new t.PopupWindowButton({text:t.message("JS_CORE_WINDOW_SAVE"),className:"popup-window-button-accept",events:{click:function(){var t=r.lastChild;e.addRule(["Sitemap",t.value]);l.close()}}}),l.closeBtn]);l.show()}})})();
//# sourceMappingURL=robots.map.js